
import { XPath, XGet, XPost, XResource } from "../../../com/lovebugs/Index"
import IndexService from '../service/IndexService';
import User from "../User";
import Persion from "../Persion";

@XPath("app")
class IndexController {

   @XResource(IndexService)
   private indexService: IndexService;

   constructor() {

   }

   @XGet("user")
   async userList(session, param) {
      let user = new User();
      user.userName = 'hyx'
      user.pwd = '123456'
      user.sex = true
      let u = await user.save()
      
      let user1 = new Persion();
      user1.userName = 'hyx1' 
      user1.sex = false
      await user1.save()

      return { code: 200, message: user1.getBeanJSON() };
   }

   @XGet("user/:id")
   async getUser(session, param) {
      let user =  await this.indexService.getUserById(param['id']);
      return { code: 200, message: user.getBeanJSON() };
   }

}

export default IndexController;